package com.web;

import com.domain.Activity;
import com.service.activityService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
 * 查询所有活动数据
 * 提交到 activityService 的 findAllActList 函数
 * 转发到 addActPlan.jsp 页面进行展示
 */
@WebServlet("/findUpdateAct")
public class findUpdateActServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.解决乱码问题
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        //2.查询所有的活动
        List<Activity> allActList = new activityService().findAllActList();
        //3.将客户id和活动转发到添加页面进行展示
        request.setAttribute("ActList",allActList);
        System.out.println("allActList = " + allActList);
        //5.进行转发
        request.getRequestDispatcher("/addActPlan.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
